# coding=utf-8
from math import *

import pygame


class Bullet(pygame.sprite.Sprite):
    def __init__(self, pos, anglex, angley):
        super(Bullet, self).__init__()
        self.r = 4  # 半径
        self.numx = anglex  # 起始角度
        self.numy = angley  # 起始角度
        self.image = pygame.image.load('0.jpg')
        self.rect = self.image.get_rect()
        self.rect.topleft = pos
        self.time = 0

    def update(self, *args):
        self.numx += 1
        self.numy += 1
        self.numx = self.numx % 360
        self.numy = self.numy % 360
        x = sin(self.numx * (pi / 180)) * self.r
        y = cos(self.numy * (pi / 180)) * self.r
        self.rect.x += x
        self.rect.y += y


class Barrage(object):
    def __init__(self):
        super(Barrage, self).__init__()


def main():
    pygame.init()
    w_size = 800, 600
    Clock = pygame.time.Clock()

    display = pygame.display.set_mode(w_size)
    group = pygame.sprite.Group()
    anglex = 0
    angley = 0
    for x in range(12):
        anglex += 10
        angley += 10
        group.add(Bullet([500, 500], anglex, angley))
    while True:
        Clock.tick(60)
        display.fill([0, 0, 0])
        for event in pygame.event.get():
            if event.type is pygame.QUIT:
                exit()
        group.update()
        group.draw(display)
        pygame.display.update()


if __name__ == '__main__':
    main()
